// https:// 协议 http + security 更安全的http
// www.mihoyo.com 域名 -> ip
// /login ———— path
// ?a=1&b=2 ———— 参数

function parseParam(url) {
    const parsesStr = /.+\?(.+)$/.exec(url)[1];
    console.log(parsesStr);
    const parsesArr = parsesStr.split('&');
    let parsesObj = {};
    parsesArr.forEach(param => {
        if (/=/.test(param)) {
            let [key, val] = param.split('=');
            // console.log(parsesArr);      
            val = decodeURIComponent(val);//解码
            if (/^\d+$/.test(val)) {
                val = parseInt(val);
            }
            if (parsesObj.hasOwnProperty(key)) {
                parsesObj[key] = [].concat(parsesObj[key], val);
            } else {
                parsesObj[key] = val;
            }
        } else {
            parsesObj[param] = undefined;
        }
    })
    return parsesObj;
}

let url = 'https://www.mihoyo.com/login?a=1&b=2&c=3&k=4&k=5&a=l&a=2&j&name=%E6%AC%A7%E9%98%B3&name=%E6%B3%93%E5%AE%87';
console.log(parseParam(url));